//
//  XXSPshopViewController.m
//  ShangChengMoBan
//
//  Created by 张铁军 on 16/9/1.
//  Copyright © 2016年 ping. All rights reserved.
//

#import "XXSPshopViewController.h"
#import "NameInputView.h"
@interface XXSPshopViewController ()
{
    NameInputView *_jinEView;
    NameInputView *_beiZhuView;
    UILabel *_shijiPayLabel;
    BaseLabel *_jinELabel;
}

@end

@implementation XXSPshopViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [self drawNavWithTitle:@"秒相符" WithColor:[UIColor whiteColor]];
    [self drawBackButton];
    [self drawView];
    
}
-(void)drawView{
    UIScrollView *backScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 64, KScreenWidth, KScreenHeight-64)];
    backScrollView.backgroundColor = LIGHTGRAYBACKCOLOR;
    [self.view addSubview:backScrollView];
    

    _jinEView = [[NameInputView alloc]initWithFrame:CGRectMake(15 * _kscW,30 * _kscH, KScreenWidth - 30 * _kscW, 80 * _kscH)andTextFont:[UIFont systemFontOfSize:18 ]];
    _jinEView.layer.cornerRadius = 10 ;
    [backScrollView addSubview:_jinEView];
    
    _beiZhuView = [[NameInputView alloc]initWithFrame:CGRectMake(_jinEView.left, _jinEView.bottom + 10 *
                                                                 _kscH, _jinEView.width, 40 * _kscH)andTextFont:[UIFont systemFontOfSize:15]];
    _beiZhuView.layer.cornerRadius = 10;
    [backScrollView addSubview:_beiZhuView];
    
    BaseLabel *shangJiaYouHui = [[BaseLabel alloc]initWithFrame:CGRectMake(_beiZhuView.left, _beiZhuView.bottom+ 15 * _kscH, _beiZhuView.width, 20 * _kscH)andFont:PuTongFont];
    shangJiaYouHui.text = @"商家优惠";
    [backScrollView addSubview:shangJiaYouHui];
    
    BaseLabel *youHuiNeiLabel = [[BaseLabel alloc]initWithFrame:CGRectMake(shangJiaYouHui.left, shangJiaYouHui.bottom, _beiZhuView.width / 3 * 2, 20 * _kscH)andFont:PuTongFont];
    youHuiNeiLabel.textColor = ZONGCOLOR;
    youHuiNeiLabel.text = @"3元代金券";
    [backScrollView addSubview:youHuiNeiLabel];
    
    _jinELabel = [[BaseLabel alloc]initWithFrame:CGRectMake(youHuiNeiLabel.right, youHuiNeiLabel.top, youHuiNeiLabel.width/2, youHuiNeiLabel.height)andFont:PuTongFont];
    _jinELabel.textColor = ZONGCOLOR;
    _jinELabel.text = @"-3.00";
    [backScrollView addSubview:_jinELabel];
    
    [backScrollView addSubview:[UILabel drawXiaHuaXianLabel:_jinELabel.bottom + 5 * _kscH]];
    
    
    BaseLabel *shiJiLabel = [[BaseLabel alloc]initWithFrame:CGRectMake(_jinEView.left, _jinELabel.bottom + 20 * _kscH, 100 * _kscW, 30 * _kscH)andFont:PuTongFont];
    shiJiLabel.textColor = MaintextColor;
    shiJiLabel.text = @"实际付款(元)";
    [backScrollView addSubview:shiJiLabel];
    
    _shijiPayLabel = [[UILabel alloc]initWithFrame:CGRectMake(shiJiLabel.right, shiJiLabel.top, _jinEView.width - shiJiLabel.width, shiJiLabel.height)];
    _shijiPayLabel.textColor = ZONGCOLOR;
    _shijiPayLabel.font = [UIFont systemFontOfSize:22 weight:2];
    _shijiPayLabel.text = [NSString stringWithFormat:@"¥%@",_firstModel.averageConsumption] ;
    _shijiPayLabel.textAlignment = NSTextAlignmentRight;
    [backScrollView addSubview:_shijiPayLabel];
    
    UIButton * xiaBu = [[UIButton alloc]initWithFrame:CGRectMake(20, _shijiPayLabel.bottom+15, KScreenWidth-40, 40)];
    [xiaBu setTitle:@"确定" forState:UIControlStateNormal];
    xiaBu.titleLabel.font = [UIFont systemFontOfSize:14];
    xiaBu.backgroundColor = [UIColor colorWithHue:1.00 saturation:1.00 brightness:1.00 alpha:1.00];
    [xiaBu setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    xiaBu.layer.cornerRadius = 4;
    [xiaBu addTarget:self action:@selector(xiaBu) forControlEvents:UIControlEventTouchUpInside];
    [backScrollView addSubview:xiaBu];

}
-(void)xiaBu{
    NSMutableDictionary * dic= [[NSMutableDictionary alloc]init];
    [dic setObject:_firstModel.userId forKey:@"offinmallUserId"];
    [dic setObject:_firstModel.averageConsumption forKey:@"money"];
    [dic setObject:[self defaultLoadUserName] forKey:@"userName"];
    [NetWorking NEWjieKouQingQiu:XXSC_createOrder ANDIP:IP And:dic anBlock:^(NSDictionary *dic, NSError *error) {
        
        if (!error) {
            if ([dic[Code] intValue] == 200) {
                NSLog(@"%@",dic[Response]);
                [[iToast makeText:@"  支付成功!  "] show];
                
            }
        }
    }];

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
